import request from '@/utils/request';

/* PositionUploadListForm {
      uploadDate (string, optional): 上传日期 ,
      uploadList (Array[FssFundStocks], optional): 解析上传数据集合
      }
  FssFundStocks {
      addtime (string, optional),
      amount (integer, optional),
      apa2 (integer, optional),
      aq (integer, optional),
      aqexposure (integer, optional),
      companyname (string, optional),
      costprice (number, optional),
      dac3 (integer, optional),
      delflag (integer, optional),
      dq (string, optional),
      dscription (string, optional),
      fundtype (integer, optional),
      id (integer, optional),
      lastscnum (integer, optional): 账上可用股数 ,
      lostprice (number, optional),
      noofshares (integer, optional),
      param1 (number, optional),
      param2 (integer, optional),
      publisher (string, optional),
      sellcall (integer, optional),
      sellput (integer, optional),
      sellputexposure (integer, optional),
      size (integer, optional),
      stock (string, optional),
      stocknumber (integer, optional): 在手股数 stock on hand ,
      stockonhandvalue (integer, optional),
      stockprice (number, optional),
      tradedate (string, optional),
      type (integer, optional),
      uploadtime (string, optional)
} */
export async function upLoadPositionStocks(params) {
  return request(`/fss/Position/PositionUpload`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function getLastDayPosition() {
  return request(`/fss/Position/LastDayPosition`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

/* PageNumForm {
num (integer, optional),
page (integer, optional): 每页数量 page从1开始 默认50个
} */
export async function getPositionSourceList(params) {
  return request(`/fss/Source/SourceList`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function deletePositionSource(params) {
  return request(`/fss/Source/DelSource?id=${params}`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

/* FssStockSource {
sourceperson (string, optional),
stock (string, optional)
} */
export async function updatePositionSource(params) {
  return request(`/fss/Source/UpdateSource`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

/* FssStockSource {
sourceperson (string, optional),
stock (string, optional)
} */
export async function addPositionSource(params) {
  return request(`/fss/Source/AddSource`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function slitPositionStocks(params) {
  return request(`/fss/Position/SplitPosition`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

/* Id , Stock , Type , CostPrice , SellPrice , StockNumber , Income , BuyDate , SellDate */
export async function getUBSSellStock() {
  return request(`/fss/Position/UBSSellStock`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

export async function updateStockSellPrice(params) {
  return request(`/fss/Position/UpdateSellPrice`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

/* FssFundOptions {
    adddate (string, optional): 根据excel文件名 获取到的日期 ,
    addtime (string, optional),
    attribute (string, optional),
    costprice (number, optional): 期权金 ,
    expiry (string, optional): 到期日 ,
    flag (integer, optional),
    fundtype (integer, optional): 基金类型 暂时填4 ,
    id (integer, optional),
    name (string, optional): 期权代码 （不用传） 传股票代码 服务器进行转换后生产 ,
    nowprice (number, optional),
    publisher (string, optional): 瑞银 ,
    stock (string, optional): 股票 ,
    stocknumber (integer, optional): 数量 ,
    stockprice (number, optional),
    strikeprice (number, optional): 期权行使价 ,
    tradedate (string, optional): 交易日 ,
    type (integer, optional): 1 sp 2 sc 3 bp 4 bc ,
    ubsid (integer, optional): 瑞银编号# ,
    updatetime (string, optional)
}] */
export async function upLoadPositionOptions(params) {
  return request(`/fss/OptionPosition/Upload`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function getLastDayOption() {
  return request(`/fss/OptionPosition/LastDayOption`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

export async function slitPositionOptions(params) {
  return request(`/fss/OptionPosition/SplitPosition`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

/* {
      "id": 3225,
      "type": 2,
      "fundtype": 4,
      "name": "ADBEUS06/21/19C280",
      x "strikeprice": 280,
      "costprice": 12.7,
      "newprice": null,
      "income": null,
      "stocknumber": 200,
      "tradedate": "2019-05-16 00:00:00",
      "expiry": "2019-06-21 00:00:00",
      "addtime": "2019-06-19 10:48:24",
      x "attribute": null,
      x "publisher": null,
      x "tradestate": 1,
      "adddate": "2019-06-07 00:00:00"
    } */
export async function getSellList() {
  return request(`/fss/OptionPosition/SellList`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}

export async function updateOptionSellPrice(params) {
  return request(`/fss/OptionPosition/UpdateSellPrice`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function getLastDayOptionByCode(params) {
  return request(`/fss/OptionPosition/LastDayOptionByCode`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function upLoadStocks(params) {
  return request(`/fss/RunPoint/StockUpload`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function upLoadBOND(params) {
  return request(`/fss/Bond/BondResetByExcel`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
    body: JSON.stringify(params),
  });
}

export async function startRunPoint() {
  return request(`/fss/RunPoint/StartRunPoint`, {
    method: 'Get',
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
    },
  });
}
